import { Random } from 'mockjs'
import { MockMethod } from 'vite-plugin-mock';
import userList from '../database/user';
import _ from 'lodash-es';
export default [
    {
        url: '/api/dev/info',
        method: 'get',
        response: ({ query }: any) => {
            return {
                code: 200,
                data: {
                    name: '张三',
                },
                message: 'success'
            }
        },
    },
    {
        url: '/api/dev/login',
        method: 'post',
        response: (value: any) => {
            const { body } = value;
            if (!body.username || !body.password) {
                return {
                    code: 500,
                    message: '用户名密码不能为空'
                }
            }

            const user = _.cloneDeep(userList.find(item => (item.username == body.username && item.password == body.password)));

            if (!user) {
                return {
                    code: 500,
                    message: '用户名密码输入错误'
                }
            }
            delete user['password'];
            return {
                code: 200,
                message: '登录成功',
                data: {
                    ...user,
                    token: Random.string(10)
                }
            }
        }
    },
    {
        url: '/api/dev/user/wait',
        method: 'get',
        response: () => {
            return {
                code: 200,
                data: {
                    list: [
                        {
                            id: Random.id(),
                            title: '勘察现场门店',
                            start: '2023-03-09 8:30:00',
                            end: '2023-03-09 9:30:00',
                            type: '看房服务'
                        },
                        {
                            id: Random.id(),
                            title: '刻晴离职申请',
                            start: '2023-03-09 10:30:00',
                            end: '2023-03-09 11:30:00',
                            type: '审批业务'
                        },
                        {
                            id: Random.id(),
                            title: '周四数据报表导出',
                            start: '2023-03-09 13:30:00',
                            end: '2023-03-09 13:40:00',
                            type: '日常提醒'
                        },
                        {
                            id: Random.id(),
                            title: '采购计算机零件审批',
                            start: '2023-03-09 14:30:00',
                            end: '2023-03-09 14:30:00',
                            type: '审批业务'
                        }
                    ]
                },
                message: 'success'
            }
        }
    },
    {
        url: '/api/dev/user/wait',
        method: 'get',
        response: () => {
            return {
                code: 200,
                data: {
                    list: [
                        {
                            id: Random.id(),
                            title: '勘察现场门店',
                            start: '2023-03-09 8:30:00',
                            end: '2023-03-09 9:30:00',
                            type: '看房服务'
                        },
                        {
                            id: Random.id(),
                            title: '刻晴离职申请',
                            start: '2023-03-09 10:30:00',
                            end: '2023-03-09 11:30:00',
                            type: '审批业务'
                        },
                        {
                            id: Random.id(),
                            title: '周四数据报表导出',
                            start: '2023-03-09 13:30:00',
                            end: '2023-03-09 13:40:00',
                            type: '日常提醒'
                        },
                        {
                            id: Random.id(),
                            title: '采购计算机零件审批',
                            start: '2023-03-09 14:30:00',
                            end: '2023-03-09 14:30:00',
                            type: '审批业务'
                        }
                    ]
                },
                message: 'success'
            }
        }
    },
    {
        url: '/api/dev/user/number',
        method: 'get',
        response: () => ({
            code: 200,
            data: [
                {
                    title: '业绩额',
                    num: '1.5',
                    source: '1.2',
                    unit: '万'
                },
                {
                    title: '签单量',
                    num: '20',
                    source: '18',
                    unit: '单'
                },
                {
                    title: '约谈量',
                    num: '18',
                    source: '16',
                    unit: '单'
                },
                {
                    title: '销售额',
                    num: '3.5',
                    source: '3.2',
                    unit: '万'
                },
                {
                    title: '营业量',
                    num: '80',
                    source: '78',
                    unit: '单'
                },
                {
                    title: '完成量',
                    num: '50',
                    source: '48',
                    unit: '单'
                }
            ],
            message: 'success'
        })
    },
    {
        url: '/api/dev/user/qd/list',
        method: 'post',
        response: ({ body }) => {
            return {
                code: 200,
                data: {
                    total: 3,
                    pageNum: 1,
                    pageSize: 10,
                    list: [
                        {
                            id: 1,
                            name: '李四',
                            phone: '',
                            address: '安徽淮北',
                            price: '1.5 万元',
                            date: '2023-03-08'
                        },
                        {
                            id: 2,
                            name: '张三',
                            phone: '15756066952',
                            address: '安徽淮北',
                            price: '1.5 万元',
                            date: '2023-03-08'

                        },
                        {
                            id: 3,
                            name: '王五',
                            phone: '15756066952',
                            address: '安徽淮北',
                            price: '1.5 万元',
                            date: '2023-03-08'
                        }
                    ]
                },
                message: 'success'
            }
        }
    }
] as MockMethod[]